//
//  InheritViewController.swift
//  test_swift
//
//  Created by fangyuan ding on 2021/5/31.
//

import UIKit
class StudDetails
{
    var mark1: Int;
    var mark2: Int;
    
    init(stm1:Int, results stm2:Int)
    {
        mark1 = stm1;
        mark2 = stm2;
    }
    
    func show()
    {
        print("Mark1:\(self.mark1), Mark2:\(self.mark2)")
    }
}

class Tom : StudDetails
{
    init()
    {
        super.init(stm1: 93, results: 89)
    }
}
class InheritViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        class StudDetails {
            var stname: String!
            var mark1: Int!
            var mark2: Int!
            var mark3: Int!
            init(stname: String, mark1: Int, mark2: Int, mark3: Int) {
                self.stname = stname
                self.mark1 = mark1
                self.mark2 = mark2
                self.mark3 = mark3
            }
        }
        let stname = "swift"
        let mark1 = 98
        let mark2 = 89
        let mark3 = 76

        let sds = StudDetails(stname:stname, mark1:mark1, mark2:mark2, mark3:mark3);

        print(sds.stname as Any)
        print(sds.mark1 as Any)
        print(sds.mark2 as Any)
        print(sds.mark3 as Any)
        
      

        let tom = Tom()
        tom.show()
        
        
//        class Circle {
//            var radius = 12.5
//            var area: String {
//                return "矩形半径 \(radius) "
//            }
//        }
//
//        // 继承超类 Circle
//        class Rectangle: Circle {
//            var print = 7
//            override var area: String {
//                return super.area + " ，但现在被重写为 \(print)"
//            }
//        }
//
//        let rect = Rectangle()
//        rect.radius = 25.0
//        rect.print = 3
//        print("Radius \(rect.area)")
        
        
        
        class Circle {
            var radius = 12.5
            var area: String {
                return "矩形半径为 \(radius) "
            }
        }

        class Rectangle: Circle {
            var print = 7
            override var area: String {
                return super.area + " ，但现在被重写为 \(print)"
            }
        }


        let rect = Rectangle()
        rect.radius = 25.0
        rect.print = 3
        print("半径: \(rect.area)")

        class Square: Rectangle {
            override var radius: Double {
                didSet {
                    print = Int(radius/5.0)+1
                }
            }
        }


        let sq = Square()
        sq.radius = 100.0
        print("半径: \(sq.area)")
        
        
      
    }
    

 

}
